# src/services/auth_service.py

from src.models.user import User
# 导入所有需要的异常类
from src.utils.exceptions import BaseException, UserNotFoundException, PasswordIncorrectException

class AuthService:
    def __init__(self):
        self.user_model = User()

    def login(self, account, password):
        """用户登录服务"""
        try:
            # 参数验证
            if not account or not password:
                raise BaseException("用户名和密码不能为空", 1005)

            # 执行登录验证
            user_info = self.user_model.verify_login(account, password)

            return user_info

        except (UserNotFoundException, PasswordIncorrectException) as e:
            # 直接抛出自定义异常，不需要包装
            raise e
        except Exception as e:
            raise BaseException(f"登录服务异常: {str(e)}", 1006)
